<!DOCTYPE html>

<html>
<head>
  <title>EventType.coffee.md</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
      <ul id="jump_to">
        <li>
          <a class="large" href="javascript:void(0);">Jump To &hellip;</a>
          <a class="small" href="javascript:void(0);">+</a>
          <div id="jump_wrapper">
          <div id="jump_page">
            
              
              <a class="source" href="Event.coffee.html">
                Event.coffee.md
              </a>
            
              
              <a class="source" href="EventRegistry.coffee.html">
                EventRegistry.coffee.md
              </a>
            
              
              <a class="source" href="EventType.coffee.html">
                EventType.coffee.md
              </a>
            
              
              <a class="source" href="Subscriber.coffee.html">
                Subscriber.coffee.md
              </a>
            
              
              <a class="source" href="header.coffee.html">
                header.coffee.md
              </a>
            
          </div>
        </li>
      </ul>
    
    <ul class="sections">
        
          <li id="title">
              <div class="annotation">
                  <h1>EventType.coffee.md</h1>
              </div>
          </li>
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              
            </div>
            
            <div class="content"><div class='highlight'><pre>	<span class="hljs-built_in">window</span>.EventType = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">EventType</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Stream</span>.<span class="hljs-title">Of</span> <span class="hljs-title">JMPromise</span></span>
	
		<span class="hljs-attribute">constructor</span>:<span class="hljs-function"> -&gt;</span>
		
			<span class="hljs-keyword">super</span>()
		
			<span class="hljs-property">@subscribers</span> = <span class="hljs-keyword">new</span> (Set.Of Subscriber)
		
			<span class="hljs-property">@each</span> <span class="hljs-function"><span class="hljs-params">(promise)</span> =&gt;</span>
				<span class="hljs-property">@subscribers</span>.each <span class="hljs-function"><span class="hljs-params">({notify,fail})</span> -&gt;</span>
					promise.<span class="hljs-keyword">then</span> notify, fail
					
		<span class="hljs-attribute">derive</span>: Function.From(Function).Returning(<span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> <span class="hljs-property">@constructor</span>() ) \
			<span class="hljs-function"><span class="hljs-params">(child)</span> -&gt;</span> <span class="hljs-function"><span class="hljs-params">(fn)</span> -&gt;</span> <span class="hljs-property">@each</span> <span class="hljs-function"><span class="hljs-params">(promise)</span> -&gt;</span> promise.<span class="hljs-keyword">then</span> fn.bind child</pre></div></div>
            
        </li>
        
        
        <li id="section-2">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-2">&#182;</a>
              </div>
              <p>Tests: full</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>		<span class="hljs-attribute">subscribe</span>: Function.delegate<span class="hljs-function"> -&gt;</span> [ <span class="hljs-property">@subscribers</span>, <span class="hljs-property">@subscribers</span>.add ]</pre></div></div>
            
        </li>
        
        
        <li id="section-3">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-3">&#182;</a>
              </div>
              <p>Tests: partial</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>		<span class="hljs-attribute">raise</span>: <span class="hljs-function"><span class="hljs-params">(args...)</span> -&gt;</span> <span class="hljs-property">@add</span> JMPromise.Fulfilled args...
		
		<span class="hljs-attribute">fail</span>: <span class="hljs-function"><span class="hljs-params">(args...)</span> -&gt;</span> <span class="hljs-property">@add</span> JMPromise.Rejected args...
		
		<span class="hljs-attribute">republish</span>: <span class="hljs-function"><span class="hljs-params">(eventtype)</span> -&gt;</span>
			<span class="hljs-property">@subscribe</span> \
				Function.delegate<span class="hljs-function"> -&gt;</span> [eventtype,eventtype.raise],
				Function.delegate<span class="hljs-function"> -&gt;</span> [eventtype,eventtype.fail]
				
		<span class="hljs-property">@Of</span>: Function.Cache.From<span class="hljs-function"><span class="hljs-params">(Function)</span> <span class="hljs-params">(constructor)</span> -&gt;</span>
			type = JMPromise.Of constructor
			<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">this</span></span>
				<span class="hljs-attribute">add</span>: Function.Of(type) <span class="hljs-attribute">this</span>::add
				<span class="hljs-attribute">raise</span>: <span class="hljs-function"><span class="hljs-params">(args...)</span> -&gt;</span> <span class="hljs-property">@add</span> type.Fulfilled args...
				<span class="hljs-attribute">fail</span>:  <span class="hljs-function"><span class="hljs-params">(args...)</span> -&gt;</span> <span class="hljs-property">@add</span> type.Rejected args...</pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>
